using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;

namespace Bll
{
	class CCommodityBiddingManage
	{
		public static CCommodityBidding CreateCommodityBidding()
       {      
           return   new CCommodityBidding();
       }
	   
	   public static CCommodityBidding Save(CCommodityBidding bidding)
	   {
			try
           {
				int num = BLL.SqlHelper.ExecuteNonQuery(CConnection.getConnString(), "sp_AddCommodityBidding", bidding.ID, bidding.userID, bidding.commodityID, bidding.price);
             
				if(0 == num)
                   return null;
                return bidding;
           }
           catch (Exception e)
           {
               return null;
           }
	   }
	   
	   public static bool Update(CCommodityBidding bidding)
	   {
			try
			{
				int num = BLL.SqlHelper.ExecuteNonQuery(CConnection.getConnString(), "sp_SaveCommodityBidding", bidding.ID, bidding.userID, bidding.commodityID, bidding.price);
				if (0 == num)
                   return false;
				return true;
			}
			catch (Exception e)
			{
               return false;
			}
	   }
	   
	   public static bool Delete(CCommodityBidding bidding)
	   {
			try
			{
				int num = BLL.SqlHelper.ExecuteNonQuery(CConnection.getConnString(), "sp_RemoveCommodityBidding", bidding.ID);
				if (0 == num)
                   return false;
				return true;
			}
			catch (Exception e)
			{
               return false;
			}
	   }
	   
	   static CCommodityBidding GetCommodityBidding(String ID)
	   {
           SqlDataReader reader = BLL.SqlHelper.ExecuteReader(CConnection.getConnString(), "sp_GetCommodityBidding", ID);

			try
           {
               if (reader.Read())
               { 
					CCommodityBidding bidding = new CCommodityBidding();
					bidding.userID = reader["userID"].ToString();
					bidding.commodityID = reader["commodityID"].ToString();
					//bidding.price = reader["price"].ToString();
					
					
					return bidding;
               }
               return null;
           }
           catch (Exception e)
           {

               return null;
           }
           finally
			{

                reader.Close();
			}
	   }
	}
}